//前端发起请求后接收到后端数据后进行一些处理操作  类似service


import {get,post} from '../utils/requst'


let findAdminList = (url,params) => {
    return get(url,params)
}


let adminAdd = (url,params) => {
    //对params进行封装
    let obj = createObj(params)
    
    console.log(obj);
    return post(url,obj)
}


let adminDelete = (url,params) => {
    return post(url,params)
}


let adminUpdate = (url,params) => {
    let obj = createObj(params)
    obj.id = params.id
    console.log(obj);
    return post(url,obj)
}

export {
    findAdminList,
    adminAdd,
    adminDelete,
    adminUpdate
}


let createObj = (params) => {
    let obj = {}
    obj.loginId = params.loginId
    obj.loginPwd = params.loginPwd
    obj.name = params.name
    obj.phone = params.phone
    obj.sex = params.sex
    obj.role = {}
    obj.role.roleName = params.roleName
    return obj
}